<?php

namespace app\admin\command;

use app\common\util\Tools;
use think\console\Input;
use think\console\Output;
use think\facade\Log;

class LineTest extends CommonTest
{
    private $enterpriseLineField = [
        "name" => "xxx", "address_from" => "require", "address_to" => "require", "car_type" => "require", "default_adult_price" => "1", "weekend_adult_price" => "1",
        "date_adult_price" => "1", "default_children_price" => "1", "weekend_children_price" => "1", "date_children_price" => "1", "default_adult_commission" => "1",
        "weekend_adult_commission" => "1", "date_adult_commission" => "1", "default_children_commission" => "1", "weekend_children_commission" => "1", "date_children_commission" => "1",
        "ride_number" => "1", "ticket_number" => "0", "driver" => "3", "shifts" => "45", "operation_time" => "sf"
    ]; //填入数据库需要存储的表字段
    private $airportLineField = [
        "name" => "xx", "address_from" => "xx", "address_to" => "require", "car_type" => "require", "default_price" => "0", "weekend_price" => "0",
        "date_price" => "0", "default_commission" => "0", "weekend_commission" => "0", "date_commission" => "0", "ride_number" => "2", "type" => "1"
    ]; //填入数据库需要存储的表字段
    private $carLineField = [
        "name" => "require", "province_code_from" => "require", "city_code_from" => "0", "area_code_from" => "0", "address_from" => "", "province_code_to" => "require", "charge_type" => 0,
        "city_code_to" => "0", "area_code_to" => "0", "address_to" => "", "car_type" => "1", "default_price" => "1", "weekend_price" => "0", "date_price" => "0", "date_between" => '',
        "default_commission" => "0", "weekend_commission" => "0", "date_commission" => "0", "ride_number" => "0", "open_default" => 1, "open_weekend" => 0, "open_date" => 0
    ]; //填入数据库需要存储的表字段

    //再命令窗口中执行“php think interface-LineTest”
    protected function configure()
    {
        $this->setName('interface-LineTest')
            ->setDescription('接口测试');
    }

    public function execute(Input $input, Output $output)
    {
        parent::execute($input, $output);

        $param["token"] = $this->token;
//        foreach (Tools::transferFields($this->enterpriseLineField) as $v => $k){
//            $param[$v] = $k;
//        }
//        echo json_encode($param) . "\n\n";

        //Route::any('admin/line/create/:type', 'admin/line/toAddLine');                                                          // 添加线路
//        $data = Tools::curl($this->url . "admin/line/create/enterprise", json_encode($param));
//        Log::write("post". var_export($data,true));
//        echo $data . "\n\n";

        //Route::any('admin/line/create/:type', 'admin/line/toAddLine');                                                          // 添加线路
//        $param["id"] = 1;
//        $data = Tools::curl($this->url . "admin/line/getDetailsById/enterprise", json_encode($param));
//        Log::write("post". var_export($data,true));
//        echo $data . "\n\n";
//
//        //Route::any('admin/line/getPageList/:type', 'admin/line/toAddLine');
//        $data = Tools::curl($this->url . "admin/line/getPageList/enterprise", json_encode($param));
//        Log::write("post". var_export($data,true));
//        echo $data . "\n\n";

        //Route::any('admin/line/getPageList/:type', 'admin/line/toAddLine');                                                          // 添加线路
//        $data = Tools::curl($this->url . "admin/line/getPageList/enterprise", json_encode($param));
//        Log::write("post". var_export($data,true));
//        echo $data . "\n\n";

        foreach (Tools::transferFields($this->carLineField) as $v => $k) {
            $param[$v] = $k;
        }
        echo json_encode($param) . "\n\n";
        //Route::any('admin/line/create/:type', 'admin/line/toAddLine');                                                          // 添加线路
        $data = Tools::curl($this->url . "admin/line/create/car", json_encode($param));
        Log::write("post". var_export($data,true));
        echo $data . "\n\n";

        //Route::any('admin/line/create/:type', 'admin/line/toAddLine');                                                          // 添加线路
//        $param["id"] =1;
//        $data = Tools::curl($this->url . "admin/line/getDetailsById/car", json_encode($param));
//        Log::write("post". var_export($data,true));
//        echo $data . "\n\n";

        //Route::any('admin/line/create/:type', 'admin/line/toAddLine');                                                          // 添加线路
//        $data = Tools::curl($this->url . "admin/line/getPageList/car", json_encode($param));
//        Log::write("post". var_export($data,true));
//        echo $data . "\n\n";

//        foreach (Tools::transferFields($this->airportLineField) as $v => $k) {
//            $param[$v] = $k;
//        }
//        echo json_encode($param) . "\n\n";
        //Route::any('admin/line/create/:type', 'admin/line/toAddLine');                                                          // 添加线路
//        $data = Tools::curl($this->url . "admin/line/getPageList/airport", json_encode($param));
//        Log::write("post". var_export($data,true));
//        echo $data . "\n\n";

        //Route::any('admin/line/create/:type', 'admin/line/toAddLine');                                                          // 添加线路
//        $param["id"] =1;
//        $data = Tools::curl($this->url . "admin/line/getDetailsById/airport", json_encode($param));
//        Log::write("post". var_export($data,true));
//        echo $data . "\n\n";

        //Route::any('admin/line/changeStatus/:type', 'admin/line/toChangeStatusLine');                                           // 更新线路的状态
//        $param["id"] =1;
//        $param["status"] =1;
//        $data = Tools::curl($this->url . "admin/line/changeStatus/airport", json_encode($param));
//        Log::write("post". var_export($data,true));
//        echo $data . "\n\n";

        //Route::any('admin/line/create/:type', 'admin/line/toAddLine');                                                          // 添加线路
//        $data = Tools::curl($this->url . "admin/line/create/airport", json_encode($param));
//        Log::write("post". var_export($data,true));
//        echo $data . "\n\n";

    }
}
